#pragma once

#include "CMCHTreeView.h"
#include "CDIADataType.h"


// CUndstandDiaUDTView view

class CUndstandDiaUDTView : public CMCHTreeView
{
private:
	struct CUndstandDiaUDTViewItem
	{
		CUndstandDiaUDTViewItem(CDIAData* pdiaData, BOOL fE=FALSE)
			:m_atpdiaData(pdiaData), fExpand(fE), dwChldNum(0)
		{};
		~CUndstandDiaUDTViewItem(){};

		std::auto_ptr<CDIAData> m_atpdiaData;
		BOOL fExpand;
		DWORD dwChldNum;
	};


protected:
	CUndstandDiaUDTView();           // protected constructor used by dynamic creation
	virtual ~CUndstandDiaUDTView();

public:
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif


public:
	CUndstandDiaDoc* GetDocument() const;

public:
	virtual void OnInitialUpdate();

protected:
	DECLARE_MESSAGE_MAP()
private:
	DECLARE_DYNCREATE(CUndstandDiaUDTView)

public:
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
	afx_msg void OnEditFilter(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnTvnItemExpand(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnTvnDeleteitem(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnTvnGetItemInfo(NMHDR *pNMHDR, LRESULT *pResult);

private:
	DWORD InsertUDT(CString* pcstrUDT);
	HTREEITEM InsertSymbol(CDIAData* pdiaData, HTREEITEM hParent=TVI_ROOT, HTREEITEM hInsertAfter=TVI_LAST);

private:
	static TCHAR* m_pszHdS[];
	static DWORD m_dwClmn;

	CComPtr<IDiaSession> m_psession;
	CComPtr<IDiaSymbol> m_pglobal;

};


